/**
 * 
 */
package cn.ivicar.passport.service;

import java.util.List;

import com.google.inject.Inject;

import cn.com.carsmart.exception.CarsmartException;
import cn.com.carsmart.ws.ibatis.model.BaseExample;
import cn.com.carsmart.ws.model.Customer;
import cn.com.carsmart.ws.service.CustomerManager;

/**
 * @author liurunbin 2017年5月16日
 */
public class PassportService {

	@Inject
	private CustomerManager customerManager;

	//根据用户手机号得到该用户对象.

	public Customer getByMobile(String mobile) {
		Customer customer = new Customer();
		customer.setMobile(mobile);
		List<Customer> list = this.customerManager.listByExample(customer);
		if (list == null || list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}
	//根据用户ID找用户对象
	public Customer get(Long customerId) {

		return this.customerManager.get(customerId);
	}
	//插入用户对象，返回数据库插入返回的结果
	public int insert(Customer customer) throws CarsmartException {
		int result = this.customerManager.insert(customer);
		return result;
	}
	//修改用户对象，返回数据库修改返回的结果
	public int updateSelective(Customer update) throws CarsmartException {
		int result = this.customerManager.updateSelective(update);
		return result;
	}
	//获取用户对象列表
	public List<Customer> get(List<Long> cidList) {
		BaseExample example = customerManager.getExample();
		example.or().andPropertyIn(cidList, "id");
		return customerManager.listByBaseExample(example);

	}
}
